let app = getApp();


var time = 0;
var touchDot = 0; //触摸时的原点
var interval = "";
var flag_hd = true;
Page({

    /**
     * 页面的初始数据
     */
    data: {
        loadModal: true,
        elements: [{
                title: '基本信息',
                name: 'Basic',
                color: 'cyan',
                icon: 'newsfill',
                url: 'msg_basis_one',
                list: '1',
            },
            {
                title: '生产管理',
                name: 'Production',
                color: 'purple',
                icon: 'font',
                url: 'msg_basis_one',
                list: '2',
            },
            {
                title: '报表 ',
                name: 'Report Form',
                color: 'mauve',
                icon: 'icon',
                url: 'msg_basis_one',
                list: '3',
            },
            // {
            //     title: '仓库管理 ',
            //     name: 'Warehouse',
            //     color: 'pink',
            //     icon: 'icon',
            //     url: 'msg_basis_one',
            //     list: '4',
            // },
        ],
        msglist: [{
                listname: '基本信息',
                smalllist: [{
                        smallname: '机器信息',
                        smallimg: '../../images/Robot.png',
                    },
                    {
                        smallname: '工序信息',
                        smallimg: '../../images/procedure.png',
                    },
                    {
                        smallname: '员工信息',
                        smallimg: '../../images/staff.png',
                    }
                ]
            },
            {
                listname: '生产管理',
                smalllist: [{
                        smallname: '生产通知单',
                        smallimg: '../../images/production.png',
                    },
                    {
                        smallname: '产量录入',
                        smallimg: '../../images/yield.png',
                    },

                ]
            },
            {
                listname: '报表',
                smalllist: [{
                    smallname: 'BI分析',
                    smallimg: '../../images/BI.png',
                }, ]
            },
            {
                listname: '仓库管理',
                smalllist: [{
                        smallname: '出库扫描',
                        smallimg: '',
                    },
                    {
                        smallname: '入库扫描',
                        smallimg: '',
                    },

                ]
            },
        ],
        indexb: '',
        indexs: '',
    },
    //点击判断页面后跳转页面
    bindview: function (e) {
        var that = this
        // console.log('点击生产信息页面返回的信息：', e);
        that.setData({
            indexb: e.currentTarget.dataset.index1,
            indexs: e.currentTarget.dataset.index2
        })
        // console.log('点击接受到的返回的信息：', that.data.indexb, that.data.indexs);
        if (that.data.indexb == 0) {
            if (that.data.indexs == 0) {
                wx.navigateTo({
                    url: '../msg_machine/msg_machine',
                })
            } else if (that.data.indexs == 1) {
                wx.navigateTo({
                    url: '../msg_procedure/msg_procedure',
                })
            } else if (that.data.indexs == 2) {
                wx.navigateTo({
                    url: '../msg_staff/msg_staff',
                })
            }
        } else if (that.data.indexb == 1) {
            if (that.data.indexs == 0) {
                wx.navigateTo({
                    url: '../msg_notice/msg_notice'
                })
            } else if (that.data.indexs == 1) {
                wx.navigateTo({
                    url: '../msg_yield/msg_yield'
                })
            } else if (that.data.indexs == 2) {
                wx.navigateTo({
                    url: '../msg_deliver/msg_deliver?deliver=' + 3,
                })
            } else if (that.data.indexs == 3) {
                wx.navigateTo({
                    url: '../msg_deliver/msg_deliver?deliver=' + 4,
                })
            }
        } else if (that.data.indexb == 2) {
            if (that.data.indexs == 0) {
                wx.navigateTo({
                    url: '../msg_BIanalysis/msg_BIanalysis',
                })
            } else if (that.data.indexs == 1) {
                wx.navigateTo({
                    url: '../msg_workshop/msg_workshop',
                })
            } else if (that.data.indexs == 2) {
                wx.navigateTo({
                    url: '../msg_paid/msg_paid',
                })
            } else if (that.data.indexs == 3) {
                wx.navigateTo({
                    url: '../msg_waijg/msg_waijg',
                })
            }

        } else if (that.data.indexb == 3) {
            if (that.data.indexs == 0) {
                wx.navigateTo({
                    url: '../msg_inventory/msg_inventory',
                })
            } else if (that.data.indexs == 1) {
                wx.navigateTo({
                    url: '../msg_allocation/msg_allocation?listid=2',
                })
            } else if (that.data.indexs == 2) {
                wx.navigateTo({
                    url: '../msg_allocation/msg_allocation?listid=3',
                })
            } else if (that.data.indexs == 3) {
                wx.navigateTo({
                    url: '../msg_allocation/msg_allocation?listid=4',
                })
            }

        } else if (that.data.indexb == 4) {
            if (that.data.indexs == 0) {
                wx.navigateTo({
                    url: '../msg_account/msg_account',
                })
            } else if (that.data.indexs == 1) {
                wx.navigateTo({
                    url: '../msg_chun/msg_chun',
                })
            } else if (that.data.indexs == 2) {
                wx.navigateTo({
                    url: '../msg_bi/mag_bi',
                })
            } else if (that.data.indexs == 3) {
                wx.navigateTo({
                    url: '../list/list?listid=4',
                })
            }
        }
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let that = this
        // setTimeout(() => console.log('Hello'), 1000)
        // setTimeout(function () {
        //     alert("Hello");
        // }, 3000);
        wx.request({
            url: 'https://' + app.globalData.url + '/staff/findStaffByLMOBILE',
            data: {
                LMOBILE: app.globalData.user_phone
            },
            method: 'GET',
            dataType: 'json',
            responseType: 'text',
            header: {
                'content-type': 'application/json;charset=utf-8'
            },
            success: function (res) {
                if (res.data.success == true) {
                    that.setData({
                        table: res.data.obj
                    })
                    app.globalData.lusercode = that.data.table[0].LUSERCODE
                    app.globalData.lusername = that.data.table[0].LUSERNAME
                } else {
                    wx.navigateTo({
                        url: '../index/index',
                    })
                    wx.showModal({
                        title: '提示',
                        content: '获取用户信息失败',
                        showCancel: false,
                        confirmText: '确定',
                        success(res) {
                            if (res.confirm) {

                            }
                        }
                    })
                }
            },
            fail: function (res) {
                wx.showModal({
                    title: '提示',
                    content: '访问服务器出错',
                    showCancel: false,
                    confirmText: '确定',
                    success(res) {
                        if (res.confirm) {

                        }
                    }
                })
            },
        })
        // wx.request({
        //     url: 'https://' + app.globalData.url + '/selectCount/find',
        //     data: {
        //         page:1,
        //         limit:10,
        //         TYPE: 1, //页码的参数名称，默认：page
        //         LPRCTYPT: '', //每页数据量的参数名，默认：limit
        //         LCLASS: '',
        //         LCLASSINDEX: '',
        //         LTICKETNO: '',
        //         BEGINDATE: "2000-01-01",
        //         ENDDATE: "2100-01-01"
        //     },
        //     method: 'GET',
        //     dataType: 'json',
        //     responseType: 'text',
        //     header: {
        //         'content-type': 'application/json;charset=utf-8'
        //     },
        //     success: function (res) {

        //     },
        //     fail: function (res) {
        //         wx.showModal({
        //             title: '提示',
        //             content: '访问服务器出错',
        //             showCancel: false,
        //             confirmText: '确定',
        //             success(res) {
        //                 if (res.confirm) {

        //                 }
        //             }
        //         })
        //     },
        // })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
        this.setData({
            loadModal: false,
        })
    },

    /**
     * 生命周期函数--监听页面显示
     */



    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})